package com.soft.link;

import com.soft.link.Interceptor.AppInterceptor;
import com.soft.link.Interceptor.CommonInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * company 重庆庆云石油工程技术有限责任公司
 * FileName WebConfigurer
 * Package com.soft.link
 * Description
 * author Administrator
 * create 2018-04-25 17:17
 * version V1.0
 */
@Configuration
public class WebConfigurer extends WebMvcConfigurerAdapter {

    @Bean
    public CommonInterceptor commonInterceptor(){
        return new CommonInterceptor();
    }

    @Bean
    public AppInterceptor appInterceptor(){
        return new AppInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则 拦截器
        // excludePathPatterns 用户排除拦截 排除拦截
        registry.addInterceptor(commonInterceptor()).addPathPatterns("/**").excludePathPatterns("/portal/**").excludePathPatterns("/app/**");
        registry.addInterceptor(appInterceptor()).addPathPatterns("/app/**");

        super.addInterceptors(registry);
    }
}
